define(function (required, exports, modules) {
  var modal = require('mods/modal');

  exports.pro_edit = function () {
    $(".pro-save").click(function () {
      if ($(this).hasClass("disabled")) {
        modal.alert("系统正在处理中~~~,请不要重复请求")
        return false
      }

      var pro_title = $('input[name=pro-name]').val()
      var cover_img = $("#pro_img").val()
      var pro_content = UE.getEditor("pro_editor").getContent()
      var _csrf = $("#csrf").val()
      var pro_id = $("input[name=pro-id]").val()

      if (pro_title.length < 1) {
        modal.alert("请填写动态标题")
        return false
      }
      if (cover_img.length < 1) {
        modal.alert("请上传动态封面图")
        return false
      }
      if (pro_content.length < 1) {
        modal.alert("请填写动态具体内容")
        return false
      }
      $(this).addClass('disabled')
      $.ajax({
        url: '/admin/project/set',
        type: 'POST',
        dataType: 'json',
        data: {
          pro_title: pro_title,
          cover_img: cover_img,
          pro_content: pro_content,
          pro_id: pro_id,
          _csrf: _csrf
        },
        success: function (res) {
          $(this).removeClass("disabled")
          if (res.code == 200) {
            modal.msg(res.msg, {}, function () {
              location.href = "/admin/project/index"
            })
          } else {
            modal.msg(res.msg, {}, function () {
              location.reload()
            })
          }
        }
      })
    })
  };
})